<template>
  <div>
    <TitleHeader :titleData="titleData" @childEvent="toNewContract"></TitleHeader>
    <div v-if="currentComponent == 'contractBoard'">
      <contract-board @send-data-to-parent='handleDataFromChild($event)'></contract-board>
    </div>
    <div v-else-if="currentComponent == 'client'">
      <client></client>
    </div>
    <div v-else-if="currentComponent == 'weeklyNewspaper'">
      <weekly-newspaper></weekly-newspaper>
    </div>
    <div v-else-if="currentComponent == 'ContractList'">
      <ContractList></ContractList>
    </div>
    <div v-else>
      <new-contract></new-contract>
    </div>
  </div>

</template>

<script>
import TitleHeader from '@/views/contract/components/TitleHeader.vue'
import ContractBoard from '@/views/contract/contractBoard/ContractBoard.vue'
import Client from '@/views/contract/client/Client.vue'
import WeeklyNewspaper from '@/views/contract/weeklyNewspaper/WeeklyNewspaper.vue'
import NewContract from '@/views/contract/newContract/NewContract.vue'
import ContractList from '@/views/contract/contractBoard/components/ContractList.vue'
export default {
  name: 'ContractIndex.vue',
  components: { ContractList, NewContract, WeeklyNewspaper, Client, ContractBoard, TitleHeader },
  data () {
    return {
      // 标题数据
      currentComponent: 'contractBoard',
      titleData: [
        { name: '合同看板', path: 'contractBoard' },
        { name: '客户', path: 'client' },
        { name: '周报', path: 'weeklyNewspaper' }
      ]

    }
  },
  created () {
    // eslint-disable-next-line no-undef
    this.createInit()
  },
  methods: {
    toNewContract (data) {
      // console.log('父组件')
      // if (this.$route.path !== '/' + data) {
      //   // 进行新增合同
      //   this.$router.push('/' + data)
      // }
    },
    createInit () {
      // if (this.$route.path !== '/contractBoard') {
      //   // 进行导航操作
      //   this.$router.push('/contractBoard')
      // }
    },
    // 判断当前点击的标题然后给他加类
    titleClick (index, patch) {
      // if (this.$route.path !== patch) {
      //   // 进行导航操作
      //   this.$router.replace(patch)
      //   this.titleClickIndex = index
      //   console.log(this.titleClickIndex)
      // }
    },
    handleDataFromChild (data) {
      this.currentComponent = data
    }
  }
}
</script>

<style scoped>

</style>
